// 创建路由:
import { createRouter, createWebHashHistory } from "vue-router";
import store from "../store"
import Home from "../views/Home.vue";

const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            path: "/",
            component: Home
        },
        {
            path: "/checkData",
            component: () => import(/* webpachChunkName: "detail" */"../views/Detail.vue"),
            beforeEnter(from, to, next){
                if(store.state.home.status){
                    next();
                }else{
                    router.replace("/")
                }
            }
        }
    ]
})

export default router;